Component({
  properties: {
    title: {
      type: String,
      value: '请选择'
    },
    options: {
      type: Array,
      value: []
    }
  },
  data: {
    isShow: false,
    startY: 0
  },
  methods: {
    show() {
      this.setData({
        isShow: true,
        startY: 0
      }, () => {
        this.setData({
          'picker-container': 'show'
        });
      });
    },
    hide() {
      this.setData({
        'picker-container': ''
      }, () => {
        setTimeout(() => {
          this.setData({
            isShow: false
          });
        }, 300);
      });
    },
    onOptionTap(e) {
      const index = e.currentTarget.dataset.index;
      const value = this.data.options[index];
      this.triggerEvent('change', { value, index });
      this.hide();
    }
  },
  ready() {
    this.setData({
      startY: 0
    });
  }
});